package com.olive.config;

import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.stereotype.Component;

@Component
public class CustomMessageHandler implements MessageHandler {

	@ServiceActivator(inputChannel = MqttListener.CHANNEL_NAME_IN)
	@Override
	public void handleMessage(Message<?> message) throws MessagingException {
		try {
			MessageHeaders messageHeaders = message.getHeaders();
			System.out.println("messageHeaders>>" + messageHeaders);
			String string = message.getPayload().toString();
			System.out.println("接收到消息：" + string);
		} catch (MessagingException e) {
			e.printStackTrace();
		}
	}

}
